import routerName from './routesName.js'
function routerLoding(router) {
    router.beforeEach(beforeEach.bind(router))//创建路由前守卫；
    router.afterEach(afterEach.bind(router))//创建路由后守卫；
}
function beforeEach(to,from,next){
    if(to.meta.title){
        document.title=to.meta.title
    }
    if(routerName.indexOf(to.name)!=-1){
        next()//判断路由名字中是否有即将跳转的页面。有放行
    }else{
        //即将跳转的路由中没有该页面阻断
        next({path:'/404'})
    }
}
function afterEach(){
    console.log('跳转完成')
}


export default routerLoding